package com.rent.product.service.impl;

import com.rent.product.dao.PmsSpuDao;
import com.rent.product.entity.PmsSpuEntity;
import com.rent.product.entity.vo.PmsValueSelect;
import com.rent.product.service.PmsSpuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Service
public class PmsSpuServicempl implements PmsSpuService {

    @Resource
    private PmsSpuDao pmsSpuDao;




    @Override
    public List<PmsSpuEntity> getpage(int cid, int pageSize, int pageNow) throws IOException {


        List<PmsSpuEntity> list = pmsSpuDao.page_Get(cid,(pageNow-1)*pageSize,pageSize);

        return list;
    }

    @Override
    public List<PmsSpuEntity> getpagesu(int cid, int key, int pageSize, int pageNow) throws IOException {


        List<PmsSpuEntity> list = pmsSpuDao.page_Getsu(cid,key,(pageNow-1)*pageSize,pageSize);

        return list;
    }

    @Override
    public List<PmsValueSelect> getValueSelect() {


        //在数据库查询得到该属性的可选值
        String nameS =pmsSpuDao.getValueSelect();

        //分割
        String[] nameStr=nameS.split(",");
        List<PmsValueSelect> nameList = new ArrayList<>();
        //封装
        for (int i = 0; i < nameStr.length; i++) {
            nameList.add(new PmsValueSelect(nameStr[i]));
        }

        return nameList;
    }


}
